﻿namespace Innovative.ProXr
{
	/// <summary>
	/// Converts an API that responds with a single byte value
	/// to an integer.
	/// </summary>
	public class Int32ResponseConverter : IResponseConverter<int>
	{
		int IResponseConverter<int>.Convert(RelayByte[] response)
		{
			int returnValue = 0;

			if (response.Length == 1)
			{
				returnValue = (int)response[0];
			}
			else
			{
				throw new InvalidResponseException("The Int32ResponseConverter converter expects a single byte response.");
			}

			return returnValue;
		}
	}
}
